package com.sky.service.impl;

import com.sky.entity.AddressBook;
import com.sky.mapper.AddressMapper;
import com.sky.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressMapper addressMapper;

    @Override
    public List<AddressBook> list(Long id) {
        return addressMapper.list(id);
    }

    @Override
    public void addAddress(AddressBook addressBook) {
        addressMapper.addAddress(addressBook);
    }

    @Override
    public AddressBook findIsDefault(Long userId) {
        return addressMapper.defaultAddress(userId);
    }

    @Override
    public void toNullDefaul(Long userId) {
        addressMapper.toNullDefaul(userId);
    }

    @Override
    public void toDefault(Long id) {
        addressMapper.toDafault(id);
    }

    @Override
    public AddressBook getAddressById(Long id) {
        return addressMapper.getAddressById(id);
    }

    @Override
    public void updateAddress(AddressBook addressBook) {
        addressMapper.updateAddress(addressBook);
    }

    @Override
    public void deleteAddress(Long id) {
        AddressBook address = addressMapper.getAddressById(id);
        addressMapper.deleteAddress(id);
    }
}
